<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Db;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {
        $this->success('请求成功');
    }

    public function test()
    {
        Db::startTrans();
        $user = (new \app\common\model\User)->where('mobile', '=', '151')->order('id asc')->lock(true)->find();
        $user->mobile = $this->request->get('m');
        $user->save();
        sleep(10);
        Db::commit();
    }

    public function test2()
    {
        $user = (new \app\common\model\User)->where('mobile', '=', '151')->order('id asc')->lock(true)->find();
        dd($user->toArray());
    }
}
